<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>主页</title>
<%@include file="static/common/common.jspf"%>
</head>
<body class="easyui-layout">
	<div data-options="region:'north',border:false" style="height:100px;background:#B3DFDA;padding:10px;float: left;">
		<div style="margin-left: 50px;width: 80%;float: left;">
			<strong><h1>权限管理系统</h1></strong>
		</div>
		<div style="margin-top:15px; float: left; width: 10%;">
			<h3>欢迎您,${user.username}<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-back" plain="true" onclick="openWin()">退出</a></h3>
		</div>
	</div>
	<div data-options="region:'west',split:true,title:'用户菜单'" style="width:250px;padding:10px;">
		<ul id="permissionTree"></ul>
	</div>
	<div data-options="region:'center',title:'主面板'">
		<div id="mainTab" class="easyui-tabs" data-options="fit:true" style="width:700px;height:250px">
	</div>
	<div data-options="region:'south',border:false" style="height:50px;background:#A9FACD;padding:10px;">
	
	</div>
	<script type="text/javascript">
	 	$("#permissionTree").tree({
			url:'menu!getMenuTreeByRoleId',
			method:'get',
			onLoadSuccess:function(){
				$("#permissionTree").tree('expandAll');
			},
			onClick:function(node){
				//判断用户点击的节点是否为叶子节点,如果为叶子节点,则打开新的窗口,为枝干节点什么都不做
				var ifLeaf = $("#permissionTree").tree('isLeaf', node.target);
				if(ifLeaf){
					
					var url = node.url;
					var title = node.text;
					
					//通过面板的标题判断是否已经打开,如果已经打开,让其选中, 如果未打开则 新增面板
					var isExists = $("#mainTab").tabs('exists', title);
					if(isExists){
						$("#mainTab").tabs('select', title);
					}else{
						var newPanel = {
							title: title,
							selected: true,
							href: url,
							closable: true
						}
						$("#mainTab").tabs('add', newPanel);
					}
				}
			}
		}) 
	
		
		function openWin(){
	 		window.location.href="login.jsp";
	 	}
	</script>
</body>
</html>